package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.QuestionMapper;
import com.tanhua.model.db.Question;
import com.tanhua.model.db.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionApiImpl implements QuestionApi {

    @Autowired
    private QuestionMapper questionMapper;

    @Override//查询陌生人问题
    public Question findByUserId(Long userId) {
        QueryWrapper<Question> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return questionMapper.selectOne(queryWrapper);

    }

    @Override//保存陌生人问题
    public void save(Question question) {
        //1. 保存
        questionMapper.insert(question);
    }

    @Override//更新陌生人问题
    public void update(Question question) {
        questionMapper.updateById(question);
    }
}
